# Python 中json 数据获取与处理
import json
origjson = {
    "data": {
        "total": 2,
        "items": [
            {
                "id": "41643174-7195-4698-9404-2acd5dae5f3b",
                "name": "remoteDesktop",
                "configuration": {
                    "name": "remoteDesktop",
                    "id": "41643174-7195-4698-9404-2acd5dae5f3b",
                    "subdomain": "",
                    "hostname": "",
                    "proto": "tcp",
                    "auth": "",
                    "addr": "3389",
                    "inspect": "",
                    "host_header": "",
                    "bind_tls": "both",
                    "crt": "",
                    "key": "",
                    "client_cas": "",
                    "remote_addr": "",
                    "region": "",
                    "disable_keep_alives": "",
                    "redirect_https": "",
                    "start_type": "enable",
                    "permanent": True,
                },
                "status": "active",
                "public_url": "tcp://24.tcp.cpolar.top:10768",
                "publish_tunnels": [
                    {
                        "name": "remoteDesktop",
                        "public_url": "tcp://24.tcp.cpolar.top:10768",
                        "proto": "tcp",
                        "addr": "tcp://127.0.0.1:3389",
                        "type": "",
                        "create_datetime": "2025-01-12T21:15:16.0027534Z",
                    }
                ],
            },
            {
                "id": "06eab491-17ca-462c-8ee1-2da21e80332e",
                "name": "website",
                "configuration": {
                    "name": "website",
                    "id": "06eab491-17ca-462c-8ee1-2da21e80332e",
                    "subdomain": "",
                    "hostname": "",
                    "proto": "http",
                    "auth": "",
                    "addr": "8080",
                    "inspect": "",
                    "host_header": "",
                    "bind_tls": "both",
                    "crt": "",
                    "key": "",
                    "client_cas": "",
                    "remote_addr": "",
                    "region": "",
                    "disable_keep_alives": "",
                    "redirect_https": "",
                    "start_type": "enable",
                    "permanent": True,
                },
                "status": "active",
                "public_url": "https://22b72fbc.r38.cpolar.top",
                "publish_tunnels": [
                    {
                        "name": "website",
                        "public_url": "http://22b72fbc.r38.cpolar.top",
                        "proto": "http",
                        "addr": "http://localhost:8080",
                        "type": "",
                        "create_datetime": "2025-01-13T00:24:38.755102Z",
                    },
                    {
                        "name": "website",
                        "public_url": "https://22b72fbc.r38.cpolar.top",
                        "proto": "https",
                        "addr": "http://localhost:8080",
                        "type": "",
                        "create_datetime": "2025-01-13T00:24:38.755102Z",
                    },
                ],
            },
        ],
    },
    "code": 20000,
    "message": "",
}

list_json_Data = []
for item in origjson["data"]["items"]:
    data = {
            "Name": item["name"],
            "Content":item["public_url"],
            "Url":item["status"],
            "localhost":item["publish_tunnels"][0]["addr"],
            "Time": item["publish_tunnels"][0]["create_datetime"],
        }
    list_json_Data.append(data) 
print(json.dumps(list_json_Data))
